package com.demo;

/*
从小球第一次落地到弹起为第一次
 */
public class TenQiu {
    public static void main(String[] args) {
        method1();
        method2();

    }
    public static void method1(){
        double s = 0;//小球走的距离
        double h = 100;//小球初始的高度
        for (int i = 1; i <=9 ; i++) {
            h = h/2;
            s=s+2*h;
        }
        System.out.println("小球走的距离 s为："+(100+s));
        System.out.println("小球第十次高度h为："+h/2);
    }
    public static void method2(){
        double s = 0;//小球走的距离
        double h = 100;//小球初始的高度
        for (int i = 1; i <=10 ; i++) {
            s+=h+h/2;
            h = h/2;
        }
        System.out.println("小球走的距离 s为："+(s-h));
        System.out.println("小球第十次高度h为："+h);
    }
}
